<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>

var arr = [1, 2, 3, 4, 5, 6, 7, 8];
//反转数组
var arr1 = arr.reverse();
var str=''
//加逗号
for (var i = 0; i < arr1.length; i+=3) { 
    var arr2=arr1.slice(i,i+3);
 
    if((i+3)<arr1.length) {
        arr2=arr2.concat(",")     
    }
    str+=arr2.join("","");
}
//转化成数组，反转数组，转化成字符串
console.log(str.split("").reverse().join("",""))
</script>
</html>